{literal}
<script type="text/javascript">
    $(document).ready(function(){
        /*$("#form_busca").validate({
            rules: {
                destinatario: { required: true },
                descricao: { required: true },
                assunto: { required: true}
            },
            messages: {
            	destinatario: {required: "Obrigatorio"},
                descricao: {required: "Obrigatorio"},
                assunto: {required: "Obrigatorio"}
            },
            submitHandler: function(form) {
				jqAjaxForm(form, "DOMWindow");
			}
        });*/

        $("#destinatario").keyup(function() {
            recuperaNomesUsuarios("lista_de_nomes",$("#destinatario").val(),'{/literal}{$_site.url}{literal}');
        });

        populaSelect("status_contrato", "{/literal}{$_site.url}{literal}", "contrato/select-status-contrato?cod={/literal}{$busca_status}{literal}");
        
    }); //fecha $(

    function irPara()
    {
        var url = $("#form_busca_cliente").serialize();
    	//jqAjaxForm(document.form_busca, "DOMWindow");
    	jqAjaxLink("{/literal}{$_site.url}{$acao}{literal}?" + url, "", "DOMWindow");
    }
    
    function voltarParaForm()
    {
        var url = $("#form_selecao_cliente").serialize();
        //alert(url);
    	//jqAjaxForm(document.form_busca, "DOMWindow");
    	$("#lista_de_clientes").show();
    	jqAjaxLink("{/literal}{$_site.url}{literal}recado/clientes-selecionados?" + url, "", "lista_de_clientes");
    	$('.ancora_filtrar_clientes').closeDOMWindow();
    }
    
    
    $("#check_all").click(function()				
    {
    	$("input[type='checkbox']").attr('checked', true);
    });

    $("#uncheck_all").click(function()				
    {
    	$("input[type='checkbox']").attr('checked', false);
    });

    $("#data_inicio").datepick({showOn: 'both'});
    $("#data_fim").datepick({showOn: 'both'});

    $("#data_inicio").mask("99/99/9999");
    $("#data_fim").mask("99/99/9999");
</script>
{/literal}
<form id="form_busca_cliente" name="form_busca_cliente" method="post" action="{$_site.url}{$acao}" onsubmit="irPara(); return false;">
    <table width="100%">
    <tr>
        <td colspan="4" class="mvTituloFundo">Filtrar Clientes</td>
    </tr>
    <tr>
        <td class="fundoTituloForm bordaFormResp" width="15%">Num. Contrato</td>
        <td class="bordaFormResp" width="15%"><input type="text" size="5" name="num_contrato" id=num_contrato" value="{$num_contrato}" class="formulario"/></td>
        <td class="fundoTituloForm bordaFormResp" width="15%">Nome Cliente</td>
        <td class="bordaFormResp" width="55%"><input type="text" name="nome_cliente" id=nome_cliente" value="{$nome_cliente}" class="formulario tamanhoForm"/></td>
    </tr>
 	<tr>
        <td class="fundoTituloForm bordaFormResp" width="15%">Status Contrato</td>
		<td valign="top" class="bordaFormResp"><select name="status_contrato" id="status_contrato" class="formulario"></select></td>
        <td class="fundoTituloForm bordaFormResp" width="15%">Per&iacute;odo </td>
        <td valign="top" class="bordaFormResp">de:&nbsp;<input type="text" name="data_inicio" id="data_inicio" class="formulario" size="10">&nbsp;&nbsp;&agrave;:&nbsp;<input type="text" name="data_fim" id="data_fim" class="formulario" size="10"></td>
        
	</tr>
 	<tr>
 		<td class="fundoTituloForm bordaFormResp" width="15%">Cliente eventual?</td>
        <td valign="top" class="bordaFormResp" colspan="5">
       	   <input type="radio" name="bln_eventual" id="bln_eventual" value="1" align="middle">Sim</input>&nbsp;&nbsp;
		   <input type="radio" name="bln_eventual" id="bln_eventual" value="0" >N&atilde;o</input>&nbsp;&nbsp;
        </td>
	</tr>
 	<tr>
        <td valign="top" colspan="4" align="center"><input type="submit" value="Buscar" class="botao"/></td>
	</tr>
    </table>
 </form>
 <br>
 <form id="form_selecao_cliente" name="form_selecao_cliente" method="post" action="{$_site.url}{$acao2}" onsubmit="voltarParaForm(); return false;">
 <div style="height:200px;overflow:auto;">
 <table width="100%" cellpadding="2" cellspacing="2">
 	<tr>
        <td colspan="5" class="mvTituloFundo">Clientes</td>
    </tr>
 	<tr>
        <td colspan="5" class="fundoTituloForm"><span id="check_all" class="brod msgNaoLida" style="cursor:pointer">[selecionar todos]</span>&nbsp;&nbsp;<span id="uncheck_all" class="brod msgNaoLida" style="cursor:pointer">[descelecionar todos]</span></td>
    </tr>
 	<tr>
        <td width="5%" valign="top" class="paddingTotal3 bgCarla bold">Marcar</td>
        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold">N&uacute;mero</td>
        <td width="70%" valign="top" class="paddingTotal3 bgCarla bold">Cliente</td>
        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold">Tipo cliente</td>
        <td width="10%" valign="top" class="paddingTotal3 bgCarla bold" nowrap="nowrap">Dt. de Validade</td>
    </tr>
 	{foreach name=lista from=$contratos item=contrato key=k}
    <tr>
        <td valign="top" class="fundoTituloForm" align="center"><input type="checkbox" name="chk_cliente{$k}" id="chk_cliente{$k}" value="{$contrato->id}"></td>
        <td valign="top" class="fundoTituloForm">{$contrato->id}</td>
        <td valign="top" class="fundoTituloForm">{$contrato->vhr_nome}</td>
        <td valign="top" class="fundoTituloForm" nowrap="nowrap">{if $contrato->bln_eventual == 1}Eventual{/if}{if $contrato->bln_eventual == 0}N&atilde;o Eventual{/if}</td>
        <td valign="top" class="fundoTituloForm" nowrap="nowrap">{if $contrato->dte_validade != ""} {$contrato->dte_validade|ConverteData:5} {else} Contrato n&atilde;o iniciado{/if}</td>
    </tr>
  	{foreachelse}
    <tr>
        <td valign="top" class="fundoTituloForm" align="center"></td>
        <td valign="top" class="fundoTituloForm" colspan="4">Nenhum cliente encontrado.</td>
    </tr>
  	{/foreach}
 	<tr>
        <td valign="top" colspan="4" align="center">
	        <input type="hidden" name="num_contratos" id="num_contratos" value="{$contratos|@count}">
	        
        </td>
	</tr>
 </table>
</div>
<center><input type="submit" value="Conclu&iacute;do" class="botao"/></center>
</form>